package source.view;

import source.model.technology.*;
import javax.swing.*;

/**
 * Provides an interface to the user to view and select certain technologies for
 * research.
 * @author Steve
 *
 */
public class TechnologyOverview extends JPanel {
	private ViewData viewData;
	private JLabel currentTech;
	private JLabel knownTech;
	private JLabel unknownTech;
	
	public TechnologyOverview(ViewData vd)
	{
		viewData = vd;
		currentTech = new JLabel();
		knownTech = new JLabel();
		unknownTech = new JLabel();
		
		setCurrentTech("nothing");	
		
		update();
		
		this.setLayout(new java.awt.GridLayout(3,1));
		

		
		this.add(currentTech);
		this.add(knownTech);
		this.add(unknownTech);
	}
	
	public void update()
	{
		removeAll();
		
		if(viewData.getCurrentPlayerObject().getResearching() == null)
			setCurrentTech("nothing");
		else
			setCurrentTech(viewData.getCurrentPlayerObject().getResearching().toString());
		
		java.util.Vector<Technology> techs = viewData.getCurrentPlayerObject().techsKnown();
		String knownTechString;
		
		knownTechString = "<html><p><b>Researched Technology:</b>";
		for(Technology current : techs)
		{
			knownTechString += "<p>" + current.toString() + "</p>";
		}
		knownTechString += "</p></html>";
		
		techs = viewData.getCurrentPlayerObject().techsAvailable();
		String unknownTechString;
		
		unknownTechString = "<html><p><b>Technologies Available:</b>";
		for(Technology current : techs)
		{
			unknownTechString += "<p>" + current.toString() + "</p>";
		}
		unknownTechString += "</p></html>";
		
		knownTech.setText(knownTechString);
		unknownTech.setText(unknownTechString);
		
		this.add(currentTech);
		this.add(knownTech);
		this.add(unknownTech);
	}
	
	private void setCurrentTech(String s)
	{
		currentTech = new JLabel("<html><p>Currently Researching: " + s + "</p><html>");
	}
}
